﻿@model Gueei.Gallery.Web.ViewModels.TagListViewModel

<ul class="tagCloud">
    @foreach (var t in Model.OrderBy(t=>t.Name))
    {
        <li data-count="@t.ItemCount">
            @Html.ActionLink(t.Name, "Tag", "Browse",
                new { Name = t.Name }, new { @class = "tag" }) <span class="count">@t.ItemCount</span>
        </li>
    }
</ul>

<script type="text/javascript">
    $(function () {

        function RGB2HTML(red, green, blue) {
            var decColor = red + 256 * green + 65536 * blue;
            return decColor.toString(16);
        }
        var largest_size = 15;
        var small_size = 8;
        var darkest = 100;
        var lightest = 255;
        var largest = $("ul.tagCloud li").data("count");
        $("ul.tagCloud li").each(function () {
            // $(this).css("font-size", ($(this).data("count") / largest) * (largest_size - small_size) + small_size + "pt");
            $("a", $(this)).css("color",
                RGB2HTML(0, 0, ($(this).data("count") / largest) * (lightest - darkest) + darkest));
        });
    });
</script>